"""哈希摘要生成器"""
def __init__(self, alg='md5', size=4096):
    self.size = size
    alg = alg.lower()
    self.hasher = getattr(__import__('hashlib'), alg.lower())()
def __call__(self, stream):
    return self.to_digest(stream)
def to_digest(self, stream):
    """生成十六进制形式的摘要"""
    for buf in iter(lambda: stream.read(self.size), b''):
        self.hasher.update(buf)
    return self.hasher.hexdigest()